import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Table';
import { rules } from '@/utils/helper/validator';
import { render } from '@/utils/common/renderUtils';
import { orgList } from "@/views/examination/TSubmission/TSubmission.api";
import { defHttp } from "@/utils/http/axios";
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '摄像头名称',
    align: "center",
    dataIndex: 'videoName'
  },
  {
    title: '摄像头id',
    align: "center",
    dataIndex: 'videoId'
  },
  {
    title: '租户号',
    align: "center",
    dataIndex: 'tenantId'
  },
  {
    title: '租户',
    align: "center",
    dataIndex: 'tenantId_dictText'
  },
  {
    title: '坐标',
    align: "center",
    dataIndex: 'lnglat',
    customRender: ({ record }) => {
      if (record.latitude && record.longitude) {
        return [record.latitude, record.longitude].join(',')
      } else {
        return ''
      }
    }
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '摄像头名称',
    field: 'videoName',
    component: 'Input',
  },
  {
    label: '摄像头id',
    field: 'videoId',
    component: 'Input',
  },
  {
    label: '租户号',
    field: 'tenantId',
    component: 'Input',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '摄像头',
    field: 'videoId',
    component: 'ApiSelect',
    // TODO:摄像头限制分页为100，
    componentProps: {
      params: { pageSize: 99 },
      api: () => defHttp.get({ url: '/video/list' }),
      resultField: 'records',
      labelField: 'name',
      valueField: 'id',
      getPopupContainer: (node) => document.body,

    },
  },
  {
    field: 'tenantId',
    component: 'JDictSelectTag',
    label: '租户',
    componentProps: {
      dictCode: 'sys_tenant,name,id',
      getPopupContainer: (node) => document.body,

    },
  },
  {
    label: '坐标',
    field: 'poi',
    component: 'AMap',
    componentProps: {
      edit: 'marker',
      search: true,
      onlyShow: false,
      zoom: 16
    }
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
